﻿var roomdata = "";
var frameindex = 0;
var waitindex = 0;
var currentop = ""; //upload,delete
var allowupdate = false;// 默认不允许操作

//向服务器确认是否可以操作数据库
function CheckUrd(data, index, op) {
    if (op === "delete" || op === "deleteroom") {
        //删除时判断选中节点
        if (tree.getSelected() === null) {
            layererr("请选择节点");
            return;
        }
    }
    currentop = op;
    roomdata = data;
    frameindex = index;
    waitindex = layload("请等待数据库更新");
    allowupdate = false;
    var json = wsorder.updatesql(window.user);
    websocket.send(JSON.stringify(json));
}

//可以进行房间数据操作
function ReadyTourdRoom() {
    allowupdate = true;
    if (currentop === "upload") {
        //房间上传
        window.RoomSave();
    }
    if (currentop === "delete") {
        //删除楼栋及房间
        window.ConfirmDeleteRoom();
    }
    if (currentop === "deleteroom") {
        //删除房间不删楼栋
        window.AskDeleteRoom();
    }
    if (currentop === "updateban") {
        //保存楼栋
        window.saveBan();
    }
    if (currentop === "deletehremployee") {
        //删除置业顾问
        window.DeleteHremployee(roomdata);
    }
    if (currentop === "clientcollection") {
        //客户加收藏数据下载
        window.LoadExcel(currentop);
    }
}

//通知后台更新数据库
function wsLoadSql() {
    var json = wsorder.loadsql(window.user);
    websocket.send(JSON.stringify(json));
}

//无法保存提示
function RoomSaveError(msg) {
    layer.msg(msg);
    layer.close(frameindex);
}

